package com.mes.basicdata.service;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.hibernate.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.bstek.dorado.annotation.DataProvider;
import com.bstek.dorado.data.provider.Page;
import com.mes.basicdata.dao.PartDao;
import com.mes.basicdata.dao.iface.IPartDao;
import com.mes.basicdata.domain.Part;
import com.mes.common.service.BasicService;

@Service
public class PartService extends BasicService<Part> {

	@Autowired
	private IPartDao pardDao;
	
	@Resource
	private PartDao partDao;
	
	/**
	 * 查询part通过drawingId、partName、partType、productDeptId
	 * @param page
	 * @param params
	 */
	@DataProvider
	public void getPartByInformation(Map<String, Object> params,Page<Part> page) {
		List<Part> list = new ArrayList<>();
		String drawingId = (String) params.get("drawingId");
		String partName = (String) params.get("partName");
		String partType = (String) params.get("partType");
		String productDeptId = (String) params.get("productDeptUid");
		partDao.getPartByInformation(drawingId,partName,partType,productDeptId,page);
	}
	
	//包含分页的多条件查询
    @DataProvider
    public void getPartByConditions(Page<Part> page, Map<String, Object> params){
    	try {
    		 pardDao.getPartByConditions(page, params);
		} catch (Exception e) {
			e.printStackTrace();
		}
    }

    //根据id查询
    @DataProvider
    public List<Part> getPartById(String partUid){
    	List<Part> list = new ArrayList<Part>();
    	try {
			Part part = pardDao.getById(partUid);
			if(part != null){
				list.add(part);
			}
			return list;
		} catch (Exception e) {
			e.printStackTrace();
			return list;
		}
    }

}
